﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Attributes
{
    class Program
    {
        public static void Main(string[] Args)
        {
            TestClassA a = new TestClassA();
            TestClassB b = new TestClassB();
            string c = "";

            PrintTestAttributes(a);
            PrintTestAttributes(b);
            PrintTestAttributes(c);
        }

        public static void PrintTestAttributes(object obj)
        {
            Type type = obj.GetType();

            TestAttribute[] AttributeArray =
               (TestAttribute[])type.GetCustomAttributes(typeof(TestAttribute),
                                                           false);

            Console.WriteLine("Class:\t{0}", type.Name);
            if (AttributeArray.Length == 0)
            {
                Console.WriteLine("There are no TestAttributes applied to this class {0}",
                                  type.Name);
                return;
            }

            TestAttribute ta = AttributeArray[0];

            ta.PrintOut();
        }
    }
}
